1 // Pharmacy Management System - C++//
2
3 // Developed By: Md. Saifuddin Tipu //
4
5 // Brought To You By code-projects.org //
6
7 //Standard Library

8
9 #include <iostream>
10 #include <stdlib.h>
11 #include <
string>
12 #include <cctype>
13 #include <cmath>
14 #include <cstdio>
15 #include <fstream>
16 #include <iomanip>
17 #define max
10
18
19 using
namespace std;
20 //the header file

21
22 class
medicineType //base class
23 {

24 public
:
25
26     
void take_order();//to take_order
27     
void delete_order(); //to delete the order
28     
void modify(); //to modify the order
29     
void order_list(); //to display the order_list
30     
void daily_summary(); //to display daily_summary
31     
void exit(); //function to exit system
32     medicineType();
//constuctor
33
34 };
35
36  medicineType::medicineType ()
37 {
38
39 }
//constructor for class CarType
40
41
42 struct
node //constract node
43 {
44     
int reciept_number;
45     
string customerName;
46     
string date;
47     
int quantity[10];
48     
string type = {"OTC"};
49     
int x, menu2[10];
50     
double amount[10];
51     
string medicineName[10]={"Probiotics","Vitamin C(500mg)","Acid Free C(500mg)","Women'S Multivate","Marino Tablet","Maxi Cal Tablet",
52     
"Amino Zinc Tablet","Burnex","Fabuloss 5","Royal Propollen"};
53     
double Medicine[10] = {2.00,3.00,1.00,4.00,1.00,5.00,7.00,4.00,3.00,5.00};
54     
double total;
55
56     node *prev;
57     node *next;
58     node *link;
59
60 }*q, *temp;
//pointer declaration
61
62
63 node *start_ptr = NULL;
64 node *head = NULL;
65 node *last = NULL;

66
67 int
main() // Main function
68 {
69
70     system(
"COLOR 0"); //Color to change background
71     medicineType medicine;
72     
int menu;
73     
do
74     {
75         system(
"cls");
76         cout<<
"\t\t\t Pharmacy Management System \n";
77         cout<<
"\t\t==================================================\n\n";
78         cout<<
"\t\t--------------------------------------------------\n";
79         cout<<
"\t\t||\t1. Take new Medicine order \t\t ||\n";
80         cout<<
"\t\t||\t2. Delete latest Medicine order\t\t ||\n";
81         cout<<
"\t\t||\t3. Modify Order List \t\t\t ||\n";
82         cout<<
"\t\t||\t4. Print the Reciept and Make Payment \t ||\n";
83         cout<<
"\t\t||\t5. Daily Summary of total Sale \t\t ||\n";
84         cout<<
"\t\t||\t6. Exit\t\t\t\t\t ||\n";
85         cout<<
"\t\t--------------------------------------------------\n";
86         cout<<
"Enter choice: ";
87
88         cin>>menu;
89
90         
switch (menu)
91         {
92         
case 1:
93             {
94                 medicine.take_order();
//function add
95                 
break;
96             }
//end case 1
97         
98         
99         
case 2:
100             {
101                 medicine.delete_order();
//function delete
102                 system(
"PAUSE");
103                 
break;
104             }
//end case 2
105             
106         
case 3:
107             {
108                 medicine.modify();
//function modify
109                 system(
"PAUSE");
110                 
break;
111             }
//end case 3
112
113         
case 4:
114             {
115                 medicine.order_list();
//function order
116                 system(
"PAUSE");
117                 
break;
118             }
//end case 4
119         
case 5:
120             {
121                 medicine.daily_summary();
//function daily_summary
122                 system(
"PAUSE");
123                 
break;
124             }
//end case 5
125         
case 6:
126             {
127                 medicine.exit();
//function exit
128                 
goto a;
129                 
break;
130             }
//end case 6
131
132         
133         
default:
134             {
135                 cout<<
"You enter invalid input\nre-enter the input\n"<<endl;
136                 
break;
137             }
//end defeault
138         }
//end Switch
139     }
while(menu!=6);//end do
140     a:
//goto
141     cout<<
"thank you"<<endl;
142     system (
"PAUSE");
143     
return 0;
144 }
//end main function
145
146
147 void
medicineType::take_order() //function to take_order
148 {
149     system(
"cls");
150     
int i;
151     
int choice, quantity, price,None;
152
153     cout <<
"\nAdd Order Details\n";
154     cout <<
"_____________________________________ \n\n";
155
156     node *temp;
157     temp=
new node;
158
159                 cout <<
"**************************************************************************\n";
160                 cout<<
"DRUGS ID"<<"\tDRUGS TYPE"<<" \t\tDRUGS NAME"<<" DRUGS PRICE(RM)"<<endl;
161                 cout <<
"**************************************************************************\n";
162                 cout<<
"0001"<<"\t"<<"\tOTC"<<"\t\t"<<" Probiotics"<<" RM 2.00"<<endl;
163                 cout<<
"0002"<<"\t"<<"\tOTC"<<"\t\t"<<" Vitamin C(500mg)"<<" RM 3.00"<<endl;
164                 cout<<
"0003"<<"\t"<<"\tOTC"<<"\t\t"<<" Acid Free C(500mg)"<<" RM 1.00"<<endl;
165                 cout<<
"0004"<<"\t"<<"\tOTC"<<"\t\t"<<" Women'S Multivate"<<" RM 4.00"<<endl;
166                 cout<<
"0005"<<"\t"<<"\tOTC"<<"\t\t"<<" Marino Tablet"<<" RM 1.00"<<endl;
167                 cout<<
"0006"<<"\t"<<"\tOTC"<<"\t\t"<<" Maxi Cal Tablet"<<" RM 5.00"<<endl;
168                 cout<<
"0007"<<"\t"<<"\tOTC"<<"\t\t"<<" Amino Zinc Tablet"<<" RM 7.00"<<endl;
169                 cout<<
"0008"<<"\t"<<"\tOTC"<<"\t\t"<<" Burnex"<<" RM 4.00"<<endl;//1353fn
170                 cout<<
"0009"<<"\t"<<"\tOTC"<<"\t\t"<<" Fabuloss 5"<<" RM 3.00"<<endl;
171                 cout<<
"0010"<<"\t"<<"\tOTC"<<"\t\t"<<" Royal Propollen"<<" RM 5.00"<<endl;
172                 cout<<
" "<<endl;
173     
174     temp =
new node;
175     cout <<
"Type Order no: ";
176     cin >> temp->reciept_number;
177     cout<<
"Enter Customer Name: ";
178     cin>> temp->customerName;
179     cout<<
"Enter Date : ";
180     cin>>temp->date;
181     cout <<
"How many Medicine would you like to order:"<< endl;
182     cout<<
"( Maximum is 10 order for each transaction ) \n";
183     cout <<
" " ;
184     cin >> temp->x;
185     
if (temp->x >10)
186     {
187         cout <<
"The Medicine you order is exceed the maximum amount of order !";
188         system(
"pause");
189     }
190     
else{
191     
for (i=0; i<temp->x; i++)
192     {
193         
194         cout <<
"Please enter your selection : "<<endl;
195         cin>> temp->menu2[i];
196         cout<<
"Medicine Name: " <<temp->medicineName[temp->menu2[i]-1]<<endl;
197         cout <<
"How many medicine do you want: ";
198         cin >> temp->quantity[i];
199         temp->amount[i] = temp->quantity[i] * temp->Medicine[temp->menu2[i]-
1];
200         cout <<
"The amount You need to pay is: " << temp->amount[i]<<" RM"<<endl;
201         system(
"PAUSE");
202                       
203     }
204     cout<<
"==========================================================================="<<endl;
205     cout <<
"Order Taken Successfully"<<endl;
206     cout<<
"==========================================================================="<<endl;
207     cout <<
"Go to Reciept Menu to Pay The Bill"<<endl;
208     cout<<
"==========================================================================="<<endl;
209     system (
"PAUSE");
210
211     temp->next=NULL;
212     
if(start_ptr!=NULL)
213     {
214         temp->next=start_ptr;
215     }
216     start_ptr=temp;
217     system(
"cls");
218 }
219 }
//End function take_order
220
221
222 void
medicineType::order_list() //Function to display receipt
223 {
224     
int i, num, num2;
225     
bool found; //variable to search
226     system(
"cls");
227     node *temp;
228
229     temp=start_ptr;
230     found =
false;
231     
232     cout<<
" Enter the Reciept Number To Print The Reciept\n";
233     cin>>num2;
234     cout<<
"\n";
235     cout<<
"==========================================================================="<<endl;
236     cout <<
"\t\tHere is the Order list\n";
237     cout<<
"==========================================================================="<<endl;
238
239
240     
if(temp == NULL) //Invalid receipt code
241     {
242         cout <<
"\tThere is no Order to show\n\t\t\tSo The List is Empty\n\n\n";
243     }
244     
while(temp !=NULL && !found)
245     {
246         
if (temp->reciept_number==num2)
247         {
248             found =
true;
249         }
250         
else
251         {
252             temp = temp -> next;
253         }
254         
if (found) //print the receipt
255         {
256         cout <<
"Reciept Number : "<<temp->reciept_number;
257         cout <<
"\n";
258         cout<<
"Customer Name: "<<temp->customerName<<endl;
259                 
260         cout<<
"Order Date : "<<temp->date<<endl;
261                 
262         cout<<
"_____________________________________________________________________________"<<endl;
263             
264         cout <<
"===============================================================================" << endl;
265         cout <<
"| Medicine Type | Medicine Name | Quantity | Total Price |" << endl;
266         cout <<
"=======++==================++================++===============++===============" << endl;
267         
for (i=0;i<temp->x;i++)
268         {
269             cout << temp->type <<
" \t\t";
270             cout<<temp->medicineName[temp->menu2[i]-
1]<<"\t\t\t ";
271             cout<<temp->quantity[i] <<
"\t\t";
272             cout<< temp->amount[i]<<
" RM"<<endl;
273             cout<<
"_________________________________________________________________________________"<<endl;
274         }
275         
276         temp->total = temp->amount[
0]+temp->amount[1]+temp->amount[2]+temp->amount[3]+temp->amount[4]+temp->amount[5]+temp->amount[6]+temp->amount[7]
277                         +temp->amount[
8]+temp->amount[9];
278         cout<<
"Total Bill is : "<<temp->total;
279         cout<<
"\n";
280         cout <<
"Type the exact amount You need to pay: ";
281         cin >> num;
282
283         cout <<
"\n";
284         cout <<
"\n";
285         cout<<
"Payment Done\nThank You\n";
286         cout <<
"\n_______________________________________________________________________________\n";
287         }
288
289
290 }
291 }
//End function order_list
292
293
294 void
medicineType::delete_order() //function to delete_order
295 {
296     system(
"cls");
297     
int i, num, count;
298     cout<<
"Enter the data you want to delete \n";
299     cin>>num;
300     node *q;
301     node *temp;
302     
bool found;
303
304     
if(start_ptr == NULL)
305         cerr<<
"Can not delete from an empty list.\n";
306     
else
307     {
308         
if(start_ptr->reciept_number == num)
309         {
310             q = start_ptr;
311             start_ptr = start_ptr->next;
312             count--;
313             
if(start_ptr == NULL)
314             last = NULL;
315             delete q;
316             cout<<
"The Reciept is Deleted Successfully"<<endl;
317         }
318         
else
319         {
320             found =
false;
321             temp = start_ptr;
322             q = start_ptr->next;
323     
324         
while((!found) && (q != NULL))
325         {
326             
if(q->reciept_number != num)
327             {
328                 temp = q;
329                 q = q-> next;
330             }
331             
else
332                 found =
true;
333         }
334
335             
if(found)
336             {
337                 temp->next = q->next;
338                 count--;
339
340                 
if(last == q)
341                 last = temp;
342                 delete q;
343                 cout<<
"The Reciept is Deleted Successfully"<<endl;
344             }
345             
else
346                 cout<<
"Item to be deleted is not in the list."<<endl;
347             }
348         }
349 }
//End function delete_order
350
351
352
353 void
medicineType::modify() //function to modify order
354 {
355  system(
"cls");
356  
int i, ch, sid;
357  
bool found;
358  found =
false;
359  temp = start_ptr;
360  cout<<
"Enter Receipt Number To Modify: ";
361  cin>>sid;
362  
if (temp==NULL && sid==0)
363  {
364     cout<<
"NO RECORD TO MODIFY..!"<<endl;
365  }
366
367  
else
368  {
369     
while(temp !=NULL && !found)
370     {
371         
if (temp->reciept_number==sid)
372         {
373             found =
true;
374         }
375         
else
376         {
377             temp = temp -> next;
378         }
379     
if (found)
380     {
381     cout <<
"Change Order Number: ";
382     cin >> temp->reciept_number;
383     cout<<
"Change Customer Name: ";
384     cin>> temp->customerName;
385     cout<<
"Change Date : ";
386     cin>>temp->date;
387     cout <<
"How many New Medicine would you like to Change:"<< endl;
388     cout<<
"( Maximum is 10 order for each transaction ) \n";
389     cout <<
" " ;
390     cin >> temp->x;
391     
if (temp->x >10)
392     {
393         cout <<
"The Medicine you order is exceed the maximum amount of order !";
394         system(
"pause");
395     }
396     
else{
397     
for (i=0; i<temp->x; i++)
398     {
399         
400         cout <<
"Please enter your selection to Change: "<<endl;
401         cin>> temp->menu2[i];
402         cout<<
"Change Medicine Name: " <<temp->medicineName[temp->menu2[i]-1]<<endl;
403         cout <<
"How many New medicine do you want: ";
404         cin >> temp->quantity[i];
405         temp->amount[i] = temp->quantity[i] * temp->Medicine[temp->menu2[i]-
1];
406         cout <<
"The amount You need to pay After Modify is: " << temp->amount[i]<<" RM"<<endl;
407         system(
"PAUSE");
408     }
409     temp = temp->next;
410     system(
"cls");
411     
412     }
413
414  cout<<
"RECORD MODIFIED....!"<<endl;
415  }
416  
else
417  {
418     
if(temp != NULL && temp->reciept_number != sid)
419     {
420     cout<<
"Invalid Reciept Number...!"<<endl;
421     }
422  }
423 }
424 }
425 }
//End modify function
426
427
428
429 void
medicineType::daily_summary() //Function to display Daily Summary
430 {
431     
int i,num;
432     system(
"cls");
433     node *temp ;
434
435     temp=start_ptr;
436
437
438     
if(temp == NULL) //Invalid receipt code
439     {
440         cout <<
"\t\t\tThere is no Order to show\n\t\t\tSo The List is Empty\n\n\n";
441     }
442     
else
443     {
444         cout<<
"\n";
445         cout<<
"==========================================================================="<<endl;
446         cout <<
" \t\tHere is the Daily Summary of All Orders \n"; //print all receipt
447         cout<<
"==========================================================================="<<endl;
448
449         
while(temp!=NULL)
450         {
451         
452                 cout <<
"Reciept Number : "<<temp->reciept_number;
453                 cout <<
"\n";
454                 cout<<
"Customer Name: "<<temp->customerName<<endl;
455                 
456                 cout<<
"Order Date : "<<temp->date<<endl;
457                 
458                 cout<<
"____________________________________________________________________________"<<endl;
459             
460                 cout <<
"==========================================================================" << endl;
461                 cout <<
"| Medicine Type | Medicine Name | Quantity | Total Price |" << endl;
462                 cout <<
"=======++==================++================++===============++==========" << endl;
463             
for (i=0;i<temp->x;i++)
464             {
465                 cout << temp->type <<
" \t\t";
466                 cout<<temp->medicineName[temp->menu2[i]-
1]<<"\t\t";
467                 cout<<temp->quantity[i] <<
"\t\t";
468                 cout<< temp->amount[i]<<
" RM"<<endl;
469                 cout<<
"_____________________________________________________________________________"<<endl;
470             }
471             
472             temp->total = temp->amount[
0]+temp->amount[1]+temp->amount[2]+temp->amount[3]+temp->amount[4]+temp->amount[5]+temp->amount[6]+temp->amount[7]
473             +temp->amount[
8]+temp->amount[9];
474             cout<<
"Total Bill is : "<<temp->total;
475         
476             cout <<
"\n";
477             cout <<
"\n";
478             cout <<
"\n_______________________________________________________________________________\n";
479                 
480             temp=temp->next;
481         }
482     }
483 }
//End daily summary
484 void
medicineType::exit() //Function to exit
485 {
486     cout<<
"\nYou choose to exit.\n"<<endl;
487 }
//end function exit
488
489
490 ///
/////////////////////////THE END OF PROGRAM//////////////////////////////////////////


Gõ tìm kiếm nhanh...